<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box{
            border: 1px solid red;
            margin: 20px 0;
        }
        .parent {
            background: #ccc;
            /* 创建 BFC */
            overflow: hidden;
        }

    </style>
</head>
<body>
    <div class="box">box1</div>
    <div class="parent">
        <div class="box">box2</div>
    </div>
</body>
</html>